<?php

/**
 * 已经按照流程图安排
 */
namespace audit\v2;


use app\common\model\School;
use app\traits\Api;

class FuJian extends Area
{

    function getAuditState($data)
    {
        if ($data['is_school']==1){
            //研究生
            if (in_array($data['education'],[6,7])){
                //学校是否在报考地区
                $school= School::where('school_name',$data['school'])->field('province,city')->find();
                $school_area = $school->province.' '.$school->city;
                if ($school_area!=$data['exam_address']){
                    //本市户籍?
                    if ($data['census']!=$data['exam_address']){
                        //没有本地居住证件
                        if ($data['dwell_card']==0){
                            return Api::error('审核不通过：非本市考生');
                        }else{
                            if ($data['dwell']!=$data['exam_address']){
                                return Api::error('审核不通过：非本市考生');
                            }
                        }
                    }
                }
            }else{
                //全日制
                if ($data['is_full_time']==0){
                    return Api::error('审核不通过：非普通高等学校全日制在校生');
                }else{
                    if ($data['study_yeah']<3){
                        return Api::error('审核不通过：未到三年级或毕业学年');
                    }

                    //专科要毕业
                    if (in_array($data['education'],[1,2,3,4])){
                        if ($data['grade']<$data['study_yeah']){
                            return Api::error('审核不通过：非毕业学年');
                        }
                    }

                    //本科
                    if ($data['education']==5){
                        if ($data['grade']<3){
                            return Api::error('审核不通过：未到三年级');
                        }
                    }

                    //学校是否在报考地区
                    $school= School::where('school_name',$data['school'])->field('province,city')->find();
                    $school_area = $school->province.' '.$school->city;
                    if ($school_area!=$data['exam_address']){
                        //本市户籍?
                        if ($data['census']!=$data['exam_address']){
                            //没有本地居住证件
                            if ($data['dwell_card']==0){
                                return Api::error('审核不通过：非本市考生');
                            }else{
                                if ($data['dwell']!=$data['exam_address']){
                                    return Api::error('审核不通过：非本市考生');
                                }
                            }
                        }
                    }
                }
            }
        }else{
            if ($data['card_type']==1){
                //本市户籍?
                if ($data['census']!=$data['exam_address']){
                    //没有本地居住证件
                    if ($data['dwell_card']==0){
                        return Api::error('审核不通过：非本市考生');
                    }else{
                        if ($data['dwell']!=$data['exam_address']){
                            return Api::error('审核不通过：非本市考生');
                        }
                    }
                }
            }
        }
        return Api::success('恭喜！您的信息成功通过验证');
    }
}